<?php

namespace app\adminapi\controller\game;

use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\game\BannerLists;
use app\adminapi\logic\game\BannerLogic;
use app\adminapi\validate\game\BannerValidate;

/**
 * 管理控制器
 * Class BannerController
 */
class BannerController extends BaseAdminController
{

    /**
     * @notes  查看软件列表
     * @return \think\response\Json
     * @date 2024/7/14 22:14
     */
    public function lists()
    {
        return $this->dataLists(new BannerLists());
    }

    /**
     * @notes  添加软件
     * @return \think\response\Json
     * @date 2024/7/14 22:14
     */
    public function add()
    {
        $params = (new BannerValidate())->post()->goCheck('add');
        $params['operator'] = $this->adminId;
        $result = BannerLogic::add($params);
        if (true === $result) {
            return $this->success('添加成功', [], 1, 1);
        }
        return $this->fail(BannerLogic::getError());
    }

    /**
     * @notes  编辑软件
     * @return \think\response\Json
     * @date 2024/7/14 22:14
     */
    public function edit()
    {
        $params = (new BannerValidate())->post()->goCheck('edit');
        $params['operator'] = $this->adminId;
        $result = BannerLogic::edit($params);
        if (true === $result) {
            return $this->success('编辑成功', [], 1, 1);
        }
        return $this->fail(BannerLogic::getError());
    }

    /**
     * @notes  删除软件
     * @return \think\response\Json
     * @date 2024/7/14 22:14
     */
    public function delete()
    {
        $params = (new BannerValidate())->post()->goCheck('delete');
        $result = BannerLogic::delete($params);
        if (true === $result) {
            return $this->success('删除成功', [], 1, 1);
        }
        return $this->fail(BannerLogic::getError());
    }

    /**
     * @notes  软件详情
     * @return \think\response\Json
     * @date 2024/7/14 22:14
     */
    public function detail()
    {
        $params = (new BannerValidate())->goCheck('detail');
        $result = BannerLogic::detail($params);
        return $this->data($result);
    }


    /**
     * @notes  更改软件状态
     * @return \think\response\Json
     * @date 2024/7/14 22:14
     */
    public function updateStatus()
    {
        $params = (new BannerValidate())->post()->goCheck('status');
        $result = BannerLogic::updateStatus($params);
        if (true === $result) {
            return $this->success('修改成功', [], 1, 1);
        }
        return $this->fail(BannerLogic::getError());
    }

    /**
     * @notes 获取软件数据
     * @return \think\response\Json
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     * @date 2022/10/13 10:39
     */
    public function all()
    {
        $result = BannerLogic::getAllData();
        return $this->data($result);
    }


}